package com.nbsystem.controller;

import com.nbsystem.entity.SysUser;
import com.nbsystem.service.SysUserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class CheckLoginController {

    @Resource
    private SysUserService sysUserService;


    @RequestMapping("checkLogin")
    public String checkLogin(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String userCode = request.getParameter("userCode");
        String userPwd = request.getParameter("userPwd");
        SysUser sysUser = sysUserService.findSysUser(userCode,userPwd);
        if (sysUser ==null){
            response.getWriter().write("0");
        }else {
            response.getWriter().write("1");
        }
        return "index";
    }
    @RequestMapping("loginCheck")
    public void loginCheck(SysUser sysUser, @RequestBody String userCode, @RequestBody String userPwd){

        sysUser = sysUserService.findSysUser(userCode,userPwd);
       String code= sysUser.getUserCode();
       String PWD = sysUser.getUserPwd();
       if (code.equals(userCode)){

       }

        System.out.println(sysUser);

    }
}
